<template>
  <div>
    <Header_h />
    <div class="sq_box_content">
      <bannerInfo :info="info" />
    </div>
    <div class="new_box_bgcolor">
      <div class="new_box">
        <div class="container">
          <section class="core_content_left core_content">
            <div class="s_flex s_align_items_center select_box">
              <div class="select_item">
                <el-select
                  v-model="realm"
                  placeholder="领域"
                  @change="handelChange"
                  clearable
                  @clear="clear"
                >
                  <el-option
                    v-for="item in options2"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  ></el-option>
                </el-select>
              </div>
              <div class="select_item">
                <el-select
                  v-model="school"
                  placeholder="院校"
                  @change="handelChange"
                  clearable
                  @clear="clear"
                >
                  <el-option
                    v-for="item in options3"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  ></el-option>
                </el-select>
              </div>
              <!-- <div class="select_item">
              <el-select
                v-model="team"
                placeholder="团队"
                @change="handelChange"
                clearable 
                @clear="clear"
              >
                <el-option
                  v-for="item in options"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </div>-->
            </div>
            <div
              class="item_list"
              v-for="(item, index) in list.list"
              :key="index"
              @click="
                $router.push({
                  path: '/web/leader/details',
                  query: { id: item.id },
                })
              "
            >
              <div class="s_flex s_justify_content_between s_flex_column">
                <div class="item_list_img">
                  <div class="img_wap">
                    <img class :src="item.tpic" alt />
                  </div>
                </div>
                <div class="right_info">
                  <div
                    class="
                      s_flex s_justify_content_between s_align_items_center
                    "
                  >
                    <div class="s_flex s_align_items_center">
                      <h3
                        class="
                          sq_tilte3
                          line_h_30
                          sq_tilte_color
                          content_spacing
                          ft_weight_800
                        "
                      >
                        {{ item.name }}
                      </h3>
                    </div>
                    <div
                      class="sq_content sq_sign_btn sq_sign_btn3"
                      @click.stop="getUrl(item)"
                    >
                      联系团队
                    </div>
                  </div>
                  <div class="sq_content sq_content_color leader_box">
                    <p class="ft_weight_400 line_h_26">
                      <span class="tag_right">所属院校:</span>
                      <el-tag size="small" class="tag_right" effect="plain">
                        {{ item.school }}
                      </el-tag>
                    </p>
                    <p class="ft_weight_400 line_h_26">
                      <span class="tag_right">科研领域:</span>
                      <el-tag size="small" class="tag_right" effect="plain">
                        {{ item.realm }}
                      </el-tag>
                    </p>
                  </div>
                </div>
              </div>
            </div>
          </section>
          <div class="pagination">
            <el-pagination
              background
              small
              @current-change="handleCurrentChange"
              :current-page="list.page"
              :page-size="5"
              layout="total, prev, pager, next, jumper"
              :total="parseInt(list.count)"
              align="left"
              :pager-count="5"
            ></el-pagination>
          </div>
        </div>
      </div>
    </div>
    <Footer />
    <signUp
      :dialogVisible="dialogVisible"
      @handleClose="handleClose"
      @submit="submit"
      :type="type"
      :text="text"
    />
    <rightMenu @moveTo="moveTo" />
  </div>
</template>

<script>
import Header_h from "@/components/Header_h";
import Footer from "@/components/Footer";
import bannerInfo from "@/components/web/bannerInfo";
import { getTeams, getLabel } from "@/api/adminWeb";
import { teamlist, consultAdd } from "@/api/web";
import rightMenu from "@/components/web/rightMenu";
import signUp from "@/components/web/signUp";
import { PAGE_BASE_URL } from "@/config";

export default {
  components: {
    Header_h,
    Footer,
    bannerInfo,
    signUp,
    rightMenu,
  },
  data() {
    return {
      info: {
        title: "优秀团队及领头人",
        content: "为顺德企业寻找高校合作搭建桥梁",
        img: require("@/assets/web/banner1.png"),
      },
      options: [],
      options2: [],
      options3: [],
      type: 7,
      realm: "",
      school: "",
      team: "",
      list: [],
      dialogVisible: false,
      text: {
        title: "咨询",
        btn: "立即咨询",
      },
    };
  },
  mounted() {
    this.getLabels();
    this.getList();
  },
  methods: {
    //点击第几页
    async handleCurrentChange(currentPage) {
      try {
        this.getList(currentPage);
      } catch (e) {
        this.$message.error(e.message);
      }
    },
    moveTo() {
      window.scrollTo(0, 0);
    },
    async handelChange() {
      this.options2 = await getLabel({
        type: 1,
        realm: this.realm,
        school: this.school,
      });
      this.options3 = await getLabel({
        type: 2,
        realm: this.realm,
        school: this.school,
      });
      this.getList();
    },
    async clear() {
      this.getList();
    },
    async getList(page = 1) {
      try {
        this.list = await teamlist({
          realm: this.realm,
          school: this.school,
          page_size: 5,
          page,
        });
        // this.list={...this.list,count:12}
      } catch (error) {
        this.$message.error(error.message);
      }
    },
    async getLabels() {
      this.options = await getTeams();
      this.options2 = await getLabel({ type: 1 });
      this.options3 = await getLabel({ type: 2 });
    },
    async handleClose() {
      this.dialogVisible = false;
    },
    async submit(form) {
      try {
        await consultAdd({
          ...form,
          from: this.url,
        });
        this.$message.success("提交成功");
      } catch (error) {
        this.$message.error(error.message);
      }
      this.dialogVisible = false;
    },
    getUrl(item) {
      this.text = {
        title:
          "请填写您的联系方式，我们工作人员将尽快与您联系，将为您提供“" +
          item.name +
          "”相关咨询服务。",
        btn: "提交",
      };
      this.type = 4;
      this.url = `${PAGE_BASE_URL}/#/web/leader/details?id=${item.id}`;
      this.dialogVisible = true;
    },
  },
};
</script>

<style lang="less" scoped>
.new_box {
  margin-top: -4%;
  position: relative;
  z-index: 1;
  margin-bottom: 60px;
}
.core_content .item_list_img {
  width: 144px;
  height: 144px;
  object-fit: contain;
  overflow: hidden;
  background: #f6f6f6;
  text-align: center;
  .img_wap {
    padding-bottom: 0;
    width: 100%;
    height: 100%;
    // position: relative;
    img {
      width: 100%;
      transition: all 0.5s ease;
      padding: 15px;
      object-fit: contain;
      &:hover {
        transform: scale(1.1);
      }
    }
  }
}

.li_active {
  width: 100%;
  background: #ffffff;
  box-shadow: 0 0 16px rgba(24, 76, 171, 0.16);
  border: none;
}

.right_info {
  width: 82%;
  // margin-left: 25px;
}

.core_content .item_list {
  padding: 23px 0;
  width: 95%;
  margin: 0 auto;
  // margin-bottom: 30px;
  background: #ffffff;
  // border: 1px solid #ced4ea;
  border-bottom: 1px solid var(--color9);
  cursor: pointer;
  transition: all 0.2s ease;
  &:last-child {
    border-bottom: 0;
  }
  // &:hover {
  //   background: #f7f9fc;
  // }
}

.core_content .item_list:last-child {
  margin-bottom: 0;
}

.content_spacing {
  margin: 10px auto;
}
.core_content_left {
  width: 100%;
  // margin-left: 60px;
  background-color: #fff;
  height: 100%;
  box-shadow: 0 0 16px rgba(24, 76, 171, 0.16);
}
.core_content_right {
  width: 25%;
  background-color: #fff;
}
.content_right_spacing {
  margin: 10px 0;
}
.list_right {
  // border-top: 1px solid #eee;
  padding: 10px 0;
  margin: 0 10px;
}
.right_title {
  margin: 0 10px;
  padding: 10px 0;
}
.tag_right {
  margin-right: 15px;
}
.pantent {
  margin-top: 10px;
  p {
    margin-right: 20px;
  }
}

.number {
  margin-bottom: 10px;
  .cril {
    width: 13px;
    height: 13px;
    background: #3377ff;
    border-radius: 50%;
    display: inline-block;
  }
}
.select_box {
  padding: 30px;
  .select_item {
    margin-right: 45px;
  }
}
.leader_box {
  margin-top: 20px;
  p {
    margin-bottom: 10px;
  }
}

@media (max-width: 750px) {
  .core_content .item_list {
    padding: 23px 15px;
    width: 100%;
  }
  .core_content .item_list_img {
    width: 100%;
    margin-bottom: 10px;
  }
  .tag_right {
    margin-right: 10px;
  }
  .select_box {
    padding: 15px;
  }
  .select_box .select_item {
    margin-right: 10px;
  }
  .right_info {
    width: 100%;
  }
}
.pagination {
  width: 90%;
  margin: 40px auto 0;
}
</style>